// index.js
// index.js
Page({
  data: {
    translateX: 0,
    cdList:[{
      "cdName":"五角大楼","money":"20/h",
      "cdName":"白宫","money":"50/h",
      "cdName":"华盛顿","money":"100/h"
    }]
  },

  onLoad: function () {
    wx.startDeviceMotionListening({
      interval: 'game'
    });

    wx.onDeviceMotionChange((res) => {
      console.log('Device Motion:', res); // 添加调试日志
      const gamma = res.gamma; // 获取设备左右倾斜的角度
      const translateX = gamma * 5; // 这里简单地将gamma乘以一个系数作为水平移动距离

      this.setData({
        translateX: translateX
      });
    });
  },

  onUnload: function () {
    // 页面卸载时停止监听设备运动变化
    wx.stopDeviceMotionListening();
  }
});
